//
//  LCWMainTabBarViewController.swift
//  MyWB
//
//  Created by 李成万 on 16/6/23.
//  Copyright © 2016年 李成万. All rights reserved.
//

import UIKit

class LCWMainTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let tabbar = LCWTabBar()
        
         tabbar.LCWDelegate = self
        self.setValue(tabbar, forKey: "tabBar")
        
        addChildVc(LCWHomeTableViewController(), imageName: "tabbar_home", title: "首页")
        addChildVc(LCWMessageTableViewController(), imageName: "tabbar_message_center", title: "消息")
        addChildVc(LCWSearchTableViewController(), imageName: "tabbar_discover", title: "发现")
        addChildVc(LCWProFileTableViewController(), imageName: "tabbar_profile", title: "我的")
    }

    func addChildVc(vc:UIViewController,imageName:String,title:String){
        
        vc.tabBarItem.image = UIImage(named: imageName)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        vc.title = title
        let nav = UINavigationController(rootViewController: vc
        )
        self.addChildViewController(nav)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

  

}

extension LCWMainTabBarViewController:ComposeBtnDelegate{
    func composeBtnClick() {
        let nav = UINavigationController(rootViewController: LCWComposeViewController())
        
        presentViewController(nav, animated: true, completion: nil)
        
        
    }
}
